﻿#include "mytimer.h"
#include "logger.h"

myTimer::myTimer(QObject *parent) : QObject(parent)
{
    timer = new QTimer(this);
    connect(timer, &QTimer::timeout, this, [=]{
        static int cnt = 0;
        if(0 == cnt%5)
        {
            Logger::Instance().LInfo(QDateTime::currentDateTime().toString("hh:mm:ss zzz\n") + "thread:" + QString::number((qint64)QThread::currentThreadId()) + "\nsingleton Logger test");
        }
        if(1 == cnt%5)
        {
            Logger::Instance().LCritical(QDateTime::currentDateTime().toString("hh:mm:ss zzz\n") + "thread:" + QString::number((qint64)QThread::currentThreadId()) + "\nsingleton Logger test");
        }
        if(2 == cnt%5)
        {
            Logger::Instance().LWarning(QDateTime::currentDateTime().toString("hh:mm:ss zzz\n") + "thread:" + QString::number((qint64)QThread::currentThreadId()) + "\nsingleton Logger test");
        }
        if(3 == cnt%5)
        {
            Logger::Instance().LError(QDateTime::currentDateTime().toString("hh:mm:ss zzz\n") + "thread:" + QString::number((qint64)QThread::currentThreadId()) + "\nsingleton Logger test");
        }
        if(4 == cnt%5)
        {
            Logger::Instance().LBingo(QDateTime::currentDateTime().toString("hh:mm:ss zzz\n") + "thread:" + QString::number((qint64)QThread::currentThreadId()) + "\nsingleton Logger test");
        }
        cnt++;
    });
    timer->start(1000);
}
